<!DOCTYPE html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            color: darkgray
        }

        .red {
            background-color: red;
        }

        .blue {
            background-color: blue;
        }
    </style>
</head>
<body>

<div id="test">
    <button @click="color='red'">点击红</button>
    <button @click="color='blue'">点击蓝</button>
    <button @click="flag=!flag">改变</button>
    <br>
    <div class="box" v-bind:class="color"></div>
    <br>
    <div class="box" :class="color"></div>
    <br>
    <div class="box" :class="{red:flag,blue:!flag}"></div>
    <br>
</div>

</body>

<script src="./node_modules/vue/dist/vue.js"></script>
<script type="text/javascript">
    let test = new Vue({
        el: "#test",
        data: {
            color: "red",
            flag:true,
        }
    })
</script>
</html>